<!DOCTYPE html>
<html lang='zh-CN'>
<head>
    <meta charset="utf-8">
    <meta name="referrer" content="no-referrer" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>商品管理</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <link href="js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <!--		连续5个上传图片-->
    <link rel="stylesheet" href="js/goodUploadImg/upload.css">
    <link rel="stylesheet" href="js/goodUploadImg/uploadImg.css">
</head>
<body>
<div class="container-fluid p-t-15">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header">
                    <div id="toolbar" class="toolbar-btn-action">
                        <form class="form-inline" method="post" id="searchForm">
                            <div class="form-group">
                                <label>商品名称:</label>
                                <input type="text" class="form-control" name="productName">
                            </div>
                            <div class="form-group">
                                <label>审核状态:</label>
                                <select class="form-control" name="productStatus" id="status_sel">
                                    <option value="">全部</option>
                                    <option value="0">审核中</option>
                                    <option value="1">审核通过</option>
                                    <option value="2">审核不通过</option>
                                    <option value="3">违规</option>
                                    <option value="4">下架</option>
                                </select>
                            </div>

                            <div class="form-group">
                                <button class="btn btn-info btn_query btn-round" type="button" id="searchFormBtn">查询</button>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-warning btn_query btn-round" type="button" id="passReview" style="display: none">批量审核</button>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-warning btn_query btn-round" type="button" id="bathXia" style="display: none">批量下架</button>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-danger btn_query btn-round" type="button" id="deleteBtn" style="display: none">删除</button>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="card-body">
                    <table id="grid_data"></table>
                </div>
            </div>
        </div>
    </div>

    <!--  添加与编辑模态框 -->
    <div class="modal fade" id="addOrEditModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">商品管理</h4>
                </div>
                <div class="modal-body">
                    <form id="addOrEditForm" action="/task/publish/EditTaskPublish" method="post" data-target="validator">
                        <div class="form-group">
                            <label class="control-label">审核状态：</label>
                            <input type="hidden" name="ids" id="ids">
                            <div>
                                <label class="checkbox-inline i-checks"> <input type="radio" name="productStatus" value="1"/>审核通过</label>
                                <label class="checkbox-inline i-checks"> <input type="radio" name="productStatus" value="2"/>审核不通过</label>
                                <label class="checkbox-inline i-checks"> <input type="radio" name="productStatus" value="3"/>违规</label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label">审核结果：</label>
                            <textarea class="form-control" id="approveResult" name="approveResult" rows="3"></textarea>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" id="sava">保存</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!--  查看详细模态框-->
    <div class="modal fade" id="showDetail" tabindex="-1"  role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <!--                    data-dismiss="modal"-->
                    <button type="button" class="close" id="close_btn"  aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">商品详情</h4>
                </div>
                <div class="modal-body">
                    <!--                    //详细-->
                    <div class="container-fluid p-t-15">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="card">
                                    <div class="card-body">
                                        <form class="form-horizontal" onsubmit="return false;">
                                            <!-- 商品id -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0" for="goods_name">商品Id</label>
                                                <div class="col-xs-8">
                                                    <p class="form-control" id="productId" name="productId"></p>
                                                </div>
                                            </div>
                                            <!-- 商品分类 -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0" for="goods_name">商品分类</label>
                                                <div class="col-xs-8">
                                                    <p class="form-control" id="productTypeName" name="productTypeName"></p>
                                                </div>
                                            </div>
                                            <!-- 商品标题 -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0" for="goods_name">商品标题</label>
                                                <div class="col-xs-8">
                                                    <input class="form-control" type="text" id="productName" name="productName" placeholder="请输入您的商品标题">
                                                </div>
                                            </div>

                                            <!-- 商品规格 -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0" for="goods_name">商品规格</label>
                                                <div class="col-xs-8">
                                                    <!--										规格一-->
                                                    <div>
                                                        <div class="row bg">
                                                            <div class="col-xs-9">
                                                                <select class="form-control gg-select" id="select-1" name="sku_one_name" size="1">
                                                                    <option value="0">规格1</option>
                                                                    <option value="1">规格2</option>
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="row bg-fb div-g-1">
                                                            <!--                                                            <div class="col-xs-4 m-tb">
                                                                                                                            <div class="input-group">
                                                                                                                                <input type="text" class="form-control i-gg i-gg-1" flag="1"/>
                                                                                                                            </div>
                                                                                                                        </div>-->
                                                        </div>
                                                    </div>
                                                    <!--										规格一结束-->

                                                    <div>
                                                        <div class="row bg">
                                                            <div class="col-xs-9">
                                                                <select class="form-control gg-select" id="select-2" name="sku_two_name" size="1">
                                                                    <option value="0">规格2</option>
                                                                    <option value="1">规格1</option>
                                                                </select>
                                                            </div>

                                                        </div>

                                                        <div class="row bg-fb div-g-2">

                                                            <!--                                                            <div class="col-xs-4 m-tb">
                                                                                                                            <div class="input-group">
                                                                                                                                <input type="text" class="form-control i-gg i-gg-2" flag="2"/>
                                                                                                                            </div>
                                                                                                                        </div>-->

                                                        </div>
                                                    </div>
                                                    <!--规格二-->
                                                </div>
                                            </div>
                                            <!-- 价格及库存 -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0">价格及库存</label>
                                                <div class="col-xs-8 bg-fb">
                                                    <table class="table table-bordered">
                                                        <thead id="gg-thead">
                                                        <!--<tr>
                                                            <th id="th-gg-1">规格一</th>
                                                            <th id="th-gg-2">规格二</th>
                                                            <th><span class="text-red">*</span>库存</th>
                                                            <th><span class="text-red" >*</span>烽鸟价（元）</th>
                                                            <th><span class="text-red">*</span>积分赠送</th>
                                                            <th><span class="text-red">*</span>代金卷赠送</th>
                                                            <th><span class="text-red">*</span>预览图</th>
                                                        </tr>-->
                                                        </thead>
                                                        <tbody id="gg-tbody">
                                                        <!--<tr>
                                                            <td>12</td>
                                                            <td>12</td>
                                                            <td>
                                                                <input class="pdd-form-input" type="text" value="">
                                                            </td>
                                                            <td>
                                                                <input class="pdd-form-input" type="text" value="">
                                                            </td>
                                                            <td>
                                                                <input class="pdd-form-input" type="text" value="">
                                                            </td>
                                                            <td>
                                                                <input class="pdd-form-input" type="text" value="">
                                                            </td>
                                                            <td>
                                                                <ul class="list-inline clearfix lyear-uploads-pic">
                                                                    &lt;!&ndash; <li>
                                                                        <img src="images/gallery/17.jpg" alt="图片三">
                                                                     </li> &ndash;&gt;
                                                                    <li class="example-p-id">
                                                                        <a class="pic-add pic-add-none" id="add-pic-btn" href="#!" title="点击上传"></a>
                                                                    </li>
                                                                </ul>
                                                            </td>
                                                        </tr>-->
                                                        </tbody>
                                                    </table>

                                                    <table class="table table-bordered div_hide" style="display: none" id="gg_table">
                                                        <thead>
                                                        <tr>
                                                            <th>总库存</th>
                                                            <th>烽鸟价（元）</th>
                                                            <th>积分赠送</th>
                                                            <th>代金券赠送</th>
                                                            <th>需要金券</th>
                                                            <th>商品货号</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        <tr>
                                                            <td id="td_kc"></td>
                                                            <td id="td_fnj"></td>
                                                            <td id="td_jfzs"></td>
                                                            <td id="td_jqzs"></td>
                                                            <td id="td_xyjq"></td>
                                                            <td>
                                                                <input class="pdd-form-input" id="hide_sphh" type="text" value="">
                                                            </td>
                                                        </tr>
                                                        </tbody>
                                                    </table>

                                                    <!--										没有填规格，默认显示的-->
                                                    <table class="table table-bordered div_show">
                                                        <thead>
                                                        <tr>
                                                            <th><span class="text-red">*</span>库存</th>
                                                            <th><span class="text-red">*</span>烽鸟价（元）</th>
                                                            <th><span class="text-red" >*</span>积分赠送</th>
                                                            <th><span class="text-red" >*</span>代金卷赠送</th>
                                                            <th><span class="text-red" >*</span>需要金券</th>
                                                            <th><span class="text-red" >*</span>商品货号</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        <tr>
                                                            <td>
                                                                <input class="pdd-form-input" id="show_kc" type="text" value="" style="width: 70px">
                                                            </td>
                                                            <td>
                                                                <input class="pdd-form-input" id="show_fnj" type="text" value="" style="width: 70px">
                                                            </td>
                                                            <td>
                                                                <input class="pdd-form-input" id="show_jfzs" type="text" value="" style="width: 70px">
                                                            </td>
                                                            <td>
                                                                <input class="pdd-form-input" id="show_jqzs" type="text" value="" style="width: 70px">
                                                            </td>
                                                            <td>
                                                                <input class="pdd-form-input" id="show_xyjq" type="text" value="" style="width: 70px">
                                                            </td>
                                                            <td>
                                                                <input class="pdd-form-input" id="show_sphh" type="text" value="" style="width: 120px">
                                                            </td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                            <!-- 市场价 -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0" for="marketPrice">市场价</label>
                                                <div class="col-xs-4">
                                                    <input class="form-control" type="text" id="marketPrice" placeholder="请输入您的商品的货号">
                                                </div>
                                            </div>

                                            <!-- 结算比例 -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0" for="settleCurrency">结算比例</label>
                                                <div class="col-xs-4">
                                                    <input class="form-control" type="text" id="settleCurrency" placeholder="请输入您的商品的货号">
                                                </div>
                                            </div>
                                            <!-- 赠与比例 -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0" for="favourCurrentcy">赠与比例</label>
                                                <div class="col-xs-4">
                                                    <input class="form-control" type="text" id="favourCurrentcy"  placeholder="请输入您的商品的货号">
                                                </div>
                                            </div>
                                            <!-- 商品图片 -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0">商品图片</label>
                                                <div class="col-xs-8">
                                                    <div class="form-controls">
                                                        <div class="upload-content">
                                                            <div class="content-img">
                                                                <ul class="content-img-list"></ul>
                                                                <div class="file">
                                                                    <i class="gcl gcladd"></i>
                                                                    <input type="file" name="file" accept="image/*" id="upload" multiple>
                                                                </div>
                                                            </div>
                                                            <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
                                                                <div class="modal-dialog modal-lg" role="document">
                                                                    <div class="img-up-content">
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <!-- 主体视频 -->
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0">主图视频比例</label>
                                                <div class="col-xs-8">
                                                    <div class="help-block">
                                                        <label class="lyear-radio radio-inline radio-primary">
                                                            <input type="radio" name="videoType" value="0"><span>1:1或16:9</span>
                                                        </label>
                                                        <label class="lyear-radio radio-inline radio-primary">
                                                            <input type="radio" name="videoType" value="1"><span>3：4</span>
                                                        </label>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0">主图视频</label>
                                                <div class="col-xs-8" >
                                                    <video id="video" style="width: 200px;height: 100px;display:none;" src="" controls="controls"></video>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0">商品描述</label>
                                                <div class="col-xs-8" id="editor">
                                                </div>
                                            </div>

                                            <h5 class="text-one">物流信息</h5>
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0">提取方式</label>
                                                <div class="col-xs-8">
                                                    <div class="help-block u-f-ac">
                                                        <label class="lyear-checkbox checkbox-primary text-none">
                                                            <input type="checkbox" checked=""><span class="m-l-10">使用物流配送</span>
                                                        </label>
                                                    </div>
                                                    <div class="row bg-fb u-f-ac p-10">
                                                        <div class="col-xs-2 col-md-3">
                                                            运费模板
                                                        </div>
                                                        <div class="col-xs-3 col-md-6">
                                                            <select class="form-control" id="example-select" name="example-select" size="1">
                                                                <option value="0">规格1</option>
                                                                <option value="1">尺寸</option>
                                                                <option value="2">型号</option>
                                                                <option value="3">款式</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <h5 class="text-one">商店分类</h5>
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0" for="goods_name"></label>
                                                <div class="col-xs-9">
                                                    <div class="help-block u-f-ac">
                                                        <input type="text" id="b_type"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <h5 class="text-one">售后服务</h5>
                                            <div class="form-group">
                                                <label class="col-xs-3 control-label font-0" for="goods_name"></label>
                                                <div class="col-xs-9">
                                                    <div class="help-block u-f-ac">
                                                        <label class="lyear-checkbox checkbox-primary text-none">
                                                            <input type="checkbox"><span class="m-l-10">提供发票</span>
                                                        </label>
                                                        <label class="lyear-checkbox checkbox-primary text-none">
                                                            <input type="checkbox"><span class="m-l-10">立即上架</span>
                                                        </label>
                                                        <label class="lyear-checkbox checkbox-primary text-none">
                                                            <input type="checkbox"><span class="m-l-10">放入仓库</span>
                                                        </label>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--                    -->
                </div>
            </div>
        </div>
    </div>


    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/bootstrap-table/bootstrap-table.js"></script>
    <script type="text/javascript" src="js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
    <script type="text/javascript" src="js/zero2one/zero2one.version.js"></script>
    <script type="text/javascript" src="js/zero2one/zero2one.core.js"></script>
    <!-- bootstrap表单验证插件 -->
    <script type="text/javascript" src="js/bootstrap-validator-master/dist/validator.js"></script>
    <!-- jquery-form表单提交插件 -->
    <script type="text/javascript" src="js/jquery-form/jquery.form.js"></script>
    <!-- bootstrap弹出框插件 -->
    <script type="text/javascript" src="js/jquery.bootstrap.min.js"></script>
    <!-- 表单填充插件 -->
    <script type="text/javascript" src="js/jquery-form/jquery.formloader.js"></script>
    <!--连续5个上传图片-->
    <script src="js/goodUploadImg/uploadImg.js"></script>

    <script type="text/javascript">

        //设置表头
        var columns = [
            {checkbox: true},
            {
                field: 'operate',
                title: '操作',
                // formatter: btnGroup,  // 自定义方法
                formatter: function (value, row, index) {
                    let html =
                        '<a href="#!" class="label label-success editable editable-click show-btn" title="详情" >详情</a>';
                    if (row.productStatus===1) {
                        html+='<a href="#!" class="label label-info editable editable-click offShelf-btn" title="下架" >下架</a>';
                    }else if (row.productStatus===0){
                        html+='<a href="#!" class="label label-warning editable editable-click check-btn" title="审核">审核</a>';
                    }
                    else if (row.productStatus===4||row.productStatus===2) {
                        html+='<a href="#!" class="label label-warning editable editable-click edit-btn" title="编辑">编辑</a>';
                        html+='<a href="#!" class="label label-danger editable editable-click onShelf-btn" title="上架">上架</a>';
                    }
                    return html;
                },
                events: {
                    'click .show-btn': function (event, value, row, index) {
                        showProduct(row);
                    },
                    'click .check-btn': function (event, value, row, index) {
                        $("#ids").val(row.productId);
                        $("#addOrEditModal").modal("show");
                    },
                    'click .edit-btn': function (event, value, row, index) {
                        window.open("tcGoodsEdit.html?id="+row.productId,"_blank");
                    },
                    'click .onShelf-btn': function (event, value, row, index) {
                        $.messager.confirm("温馨提示", "您确定要上架id为"+row.productId+"商品吗?", function () {
                            //发送请求,执行批量删除
                            $.post("/remote/tcProduct/tcOnShelf",{"ids": row.productId},function (res) {
                                if (res.success){
                                    $.messager.alert("温馨提示", "操作成功");
                                    $('#grid_data').bootstrapTable('refresh');
                                }else {
                                    $.messager.alert("温馨提示","操作失败");
                                }
                            });
                        });
                    },
                    'click .offShelf-btn': function (event, value, row, index) {
                        $.messager.confirm("温馨提示", "您确定要下架id为"+row.productId+"的商品吗?", function () {
                            //发送请求,执行批量删除
                            $.post("/remote/tcProduct/tcOffShelf",{"ids": row.productId},function (res) {
                                if (res.success){
                                    $.messager.alert("温馨提示", "操作成功");
                                    $('#grid_data').bootstrapTable('refresh');
                                }else {
                                    $.messager.alert("温馨提示","操作失败");
                                }
                            });
                        });
                    }
                }
            },
            {field: 'productId',title: '商品id'},
            {field: 'businessId',title: '商家id',visible: false},
            {field: 'businessName',title: '商家名称'},
            {field: 'productTypeIds',title: '商品类型',visible: false},
            {field: 'productTypeName',title: '商品类型名称'},
            {field: 'productName',title: '商品名称'},
            {field: 'barCode',title: '商品条形码'},
            {field: 'productPrice',title: '烽鸟价'},
            {field: 'marketPrice',title: '市场价格'},
            {field: 'productDiscount',title: '商品折扣',visible: false},
            {field: 'settleCurrency',title: '结算比例'},
            {field: 'favourCurrentcy',title: '赠与比例'},
            {field: 'productStock',title: '库存'},
            {field: 'soldStock',title: '已售数量'},
            {field: 'warningValue',title: '商品预警值'},
            {field: 'productCode',title: '商品货号'},
            {field: 'productDesc',title: '商品描述',visible: false},
            {field: 'isInvoice',title: '是否开增值税发票',formatter: function (value, row, index) {
                    if (value == 0) {
                        return "否";
                    }else if(value==1){
                        return "是";
                    }
                },visible: false},
            {field: 'isPublish',title: '是否发布',formatter: function (value, row, index) {
                    if (value == 1) {
                        return "立即发布";
                    }else if(value==2){
                        return "放入仓库中";
                    }
                },visible: false},
            {field: 'isRecommend',title: '是否推荐',formatter: function (value, row, index) {
                    if (value == 0) {
                        return "否";
                    }else if(value==1){
                        return "是";
                    }
                },visible: false},
            {field: 'isNew',title: '是否新品',formatter: function (value, row, index) {
                    if (value == 0) {
                        return "否";
                    }else if(value==1){
                        return "是";
                    }
                },visible: false},
            {field: 'subGraphone',title: '商品主图路径',visible: false},
            {field: 'applyTime',title: '申请时间',formatter: function (value) {
                    return zero2one.dateFormat(value, 'Y-m-d H:i:s')
                }},
            {field: 'approveName',title: '审核人'},
            {field: 'approveTime',title: '审核时间', formatter: function (value) {
                    if (value){
                        return zero2one.dateFormat(value, 'Y-m-d H:i:s')
                    }
                }},
            {field: 'productStatus',title: '审核状态',formatter: function (value, row, index) {
                    if (value == 0) {
                        return "审核中";
                    }else if(value==1){
                        return "审核通过";
                    }else if(value==2){
                        return "审核不通过";
                    }else if(value==3){
                        return "违规";
                    }else if(value==4){
                        return "下架";
                    }else if(value==5){
                        return "删除";
                    }
                }},
            {field: 'approveResult',title: '审核结果'},
            {field: 'videoSrc',title: '视频地址',visible: false},
            {field: 'skuOneName',title: '规格一名称',visible: false},
            {field: 'skuOne',title: '规格一属性值',visible: false},
            {field: 'skuTwoName',title: '规格二名称',visible: false},
            {field: 'giveJf',title: '积分赠送',visible: false},
            {field: 'giveVoucher',title: '金券赠送',visible: false},
            {field: 'needJq',title: '需要金券',visible: false},
            {field: 'subGraphList',title: '商品图片数组',visible: false},
            {field: 'bussTypeId',title: '店铺分类',visible: false},
            {field: 'viewsCount',title: '浏览次数',visible: false},
            {field: 'sort',title: '排序',visible: false},
            {field: 'skuTwo',title: '规格二属性值',visible: false}
        ];
        // 操作方法 - 查看
        function showProduct(row) {
            //先清空
            $("#gg-tbody").empty();
            $("#gg-thead").empty();
            $('.div-g-1').empty();
            $('.div-g-2').empty();
            $("#select-1").empty();
            $("#select-2").empty();
            $('#video').css("display","none");//不展示div
            $('#yz_div').css("display","none");//不展示div
            $("#productId").text(row.productId);
            $("#productTypeName").text(row.productTypeName);
            $("#productName").val(row.productName);
                $.post("/remote/BusinCates/selectCategoryName",{id:row.bussTypeId},function (res) {
                    $("#b_type").val(res.data);
                });
            if (row.skuOneName){
                $("#select-1").append('<option>'+row.skuOneName+'</option>');
                var skuOneArr=[];
                skuOneArr=JSON.parse(row.skuOne);
                var str='';
                for (var i = 0; i < skuOneArr.length; i++) {
                    str+='<div class="col-xs-4 m-tb">\n' +
                        '<div class="input-group">\n' +
                        '<input type="text" class="form-control i-gg i-gg-1" flag="1" value="'+skuOneArr[i]+'"/>\n' +
                        '</div>\n' +
                        '</div>';
                }
                $('.div-g-1').append(str)
            }
            if (row.skuTwoName){
                $("#select-2").append('<option>'+row.skuTwoName+'</option>');
                var skuTwoArr=[];
                skuTwoArr=JSON.parse(row.skuTwo);
                var str='';
                for (var i = 0; i < skuTwoArr.length; i++) {
                    str+='<div class="col-xs-4 m-tb">\n' +
                        '<div class="input-group">\n' +
                        '<input type="text" class="form-control i-gg i-gg-2" flag="2" value="'+skuTwoArr[i]+'"/>\n' +
                        '</div>\n' +
                        '</div>';
                }
                $('.div-g-2').append(str)
            }
            //查找有没有skulist
            $.post("/remote/sku/tcSkuByProId",{proId:row.productId},function (res) {
                if (res.success){
                    var skuArr=res.data;
                    if (skuArr.length===1&&row.skuOneName==null){
                        //代表没有规格
                        $("#show_kc").val(row.productStock);
                        $("#show_fnj").val(row.fnPrice);
                        $("#show_jfzs").val(row.giveJf);
                        $("#show_jqzs").val(row.giveVoucher);
                        $("#show_xyjq").val(row.needJq);
                        $("#show_sphh").val(row.productCode);
                        $('.div_show').css("display","block");//显示div
                        $('.div_hide').css("display","none");//展示div
                    } else {
                        $('.div_show').css("display","none");//不显示div
                        $('.div_hide').css("display","block");//展示div
                        //有规格
                        if (row.skuTwoName!=null){
                            var str='<tr>\n' +
                                '<th id="th-gg-">'+row.skuOneName+'</th>\n' +
                                '<th id="th-gg-">'+row.skuTwoName+'</th>\n' +
                                '<th style="width: auto"><span class="text-red">*</span>库存</th>\n' +
                                '<th style="width: auto"><span class="text-red" >*</span>烽鸟价（元）</th>\n' +
                                '<th style="width: auto"><span class="text-red">*</span>积分赠送</th>\n' +
                                '<th style="width: auto"><span class="text-red">*</span>代金卷赠送</th>\n' +
                                '<th style="width: auto"><span class="text-red">*</span>需要金券</th>\n' +
                                '<th style="width: auto"><span class="text-red">*</span>预览图</th>\n' +
                                '</tr>';
                            $("#gg-thead").append(str);
                            str='';
                            //遍历数组拿出数组
                            for (var i = 0; i < skuArr.length; i++) {
                                str+='<tr>\n' +
                                    '<td>'+skuArr[i].skuOne+'</td>\n' +
                                    '<td>'+skuArr[i].skuTwo+'</td>\n' +
                                    '<td>\n' +
                                    '<input style="width: 70px" class="pdd-form-input kc "type="text" value="'+skuArr[i].productStock+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<input style="width: 70px" class="pdd-form-input fnj "type="text" value="'+skuArr[i].fnPrice+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<input style="width: 70px" class="pdd-form-input jfzs" type="text" value="'+skuArr[i].giveJf+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<input style="width: 70px" class="pdd-form-input jqzs" type="text" value="'+skuArr[i].giveVoucher+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<input style="width: 70px" class="pdd-form-input xujq" type="text" value="'+skuArr[i].needJq+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<div style="width: 120px"><img src="'+skuArr[i].picture+'"></div>\n'+
                                    '</td>\n' +
                                    '</td>\n' +
                                    '</tr>'

                            }
                            $("#gg-tbody").append(str);
                        } else {
                            var str='<tr>\n' +
                                '<th id="th-gg">'+row.skuOneName+'</th>\n' +
                                '<th><span class="text-red">*</span>库存</th>\n' +
                                '<th><span class="text-red" >*</span>烽鸟价（元）</th>\n' +
                                '<th><span class="text-red">*</span>积分赠送</th>\n' +
                                '<th><span class="text-red">*</span>代金卷赠送</th>\n' +
                                '<th><span class="text-red">*</span>需要金券</th>\n' +
                                '<th><span class="text-red">*</span>预览图</th>\n' +
                                '</tr>';
                            $("#gg-thead").append(str);
                            str='';
                            //遍历数组拿出数组
                            for (var i = 0; i < skuArr.length; i++) {
                                str+='<tr>\n' +
                                    '<td>'+skuArr[i].skuOne+'</td>\n' +
                                    '<td>\n' +
                                    '<input  style="width: 70px" class="pdd-form-input kc "type="text" value="'+skuArr[i].productStock+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<input  style="width: 70px" class="pdd-form-input fnj "type="text" value="'+skuArr[i].fnPrice+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<input  style="width: 70px" class="pdd-form-input jfzs" type="text" value="'+skuArr[i].giveJf+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<input  style="width: 70px" class="pdd-form-input jqzs" type="text" value="'+skuArr[i].giveVoucher+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<input  style="width: 70px" class="pdd-form-input xujq" type="text" value="'+skuArr[i].needJq+'">\n' +
                                    '</td>\n' +
                                    '<td>\n' +
                                    '<input  style="width: 70px" type="hidden" name="logo" id="up-'+skuArr[i].skuId+'">\n'+
                                    '<div style="width: 120px"><img src="'+skuArr[i].picture+'"></div>\n'+
                                    '</td>\n' +
                                    '</td>\n' +
                                    '</tr>'

                            }
                            $("#gg-tbody").append(str);
                        }
                        //设置总库存那一行
                        $("#td_kc").text(row.productStock);
                        $("#td_fnj").text(row.productPrice);
                        $("#td_jfzs").text(row.giveJf);
                        $("#td_jqzs").text(row.giveVoucher);
                        $("#td_xyjq").text(row.needJq);
                        $("#hide_sphh").val(row.productCode);
                    }
                }
            });
            $("#marketPrice").val(row.marketPrice);
            $("#settleCurrency").val(row.settleCurrency);
            $("#favourCurrentcy").val(row.favourCurrentcy);

            if (row.subGraphList!=null){
                setImgSrc(JSON.parse(row.subGraphList),10);
            }else {
                $('.content-img .file').hide();
            }
            if (row.videoSrc!=null){
                $('#video').css("display","block");//不展示div
                $('#video').attr("src",row.videoSrc);
            }
            $("#editor").html(row.productDesc);
            $("#showDetail").modal("show");
        }

        //详情关闭按钮
        $("#close_btn").click(function () {
            var media = document.getElementById("video");
            media.pause(); //暂停
            $("#showDetail").modal("hide");
        });

        //进入主界面加载数据
        zero2one.datagrid("grid_data", "/remote//tcProduct/tcProductPage",function (params) {
            return $.extend(zero2one.tableInitParam(params), zero2one.form2json("searchForm"));
        }, columns);

        //点击查询按钮重新加载页面数据
        $("#searchFormBtn").click(function () {
            $('#grid_data').bootstrapTable('refresh');
            $("#passReview").css("display","none");
            $("#bathXia").css("display","none");
            $("#deleteBtn").css("display","none");
            if ($('#status_sel').val()==='0'){
                $("#passReview").css("display","block");
            }else if ($('#status_sel').val()==='1'){
                $("#bathXia").css("display","block");
            }
            else if ($('#status_sel').val()==='4'){
                $("#deleteBtn").css("display","block");
            }
        });

        //点击批量下架按钮
        $("#bathXia").click(function (){
            //获取选中行的数据
            var datas = $('#grid_data').bootstrapTable('getSelections');
            //判断是否选中行数据，如果没有则提示
            if(datas.length > 0){
                $.messager.confirm("温馨提示", "您确定要下架选中的商品吗?", function () {
                    var arr=[];
                    for (var i = 0; i < datas.length; i++) {
                        var object={};
                        object.productId=datas[i].productId;
                        object.plateId=datas[i].plateId;
                        arr.push(object)
                    }
                    console.log(arr);
                    //发送请求,执行批量下架
                    $.ajax({
                        url: '/remote/product/bathOffShelf',
                        contentType:'application/json',
                        type: 'post',
                        data: JSON.stringify(arr),
                        dataType: 'json',
                        success: function (res) {
                            if (res.success){
                                $.messager.alert("温馨提示", "操作成功");
                                $('#grid_data').bootstrapTable('refresh');
                            }else {
                                $.messager.alert("温馨提示","操作失败");
                            }
                        }
                    });
                });
            }else{
                $.messager.alert("温馨提示", "请选择一条数或多条据操作");
            }
        });

        //点击批量审核按钮弹出模态框
        $("#passReview").click(function (){
            //获取选中行的数据
            var datas = $('#grid_data').bootstrapTable('getSelections');
            //判断是否选中行数据，如果没有则提示
            if(datas.length > 0){
                var ids='';
                //填充表单
                for (var i = 0; i < datas.length; i++) {
                    ids+=','+datas[i].productId;
                }
                $("#ids").val(ids.substring(1,ids.length));
            }else{
                $.messager.alert("温馨提示", "请选择一条数或多条据操作");
                return;
            }
            $("#addOrEditModal").modal("show");
        });

        //保存按钮的点击事件
        $("#sava").click(function () {
            zero2one.request("/remote/tcProduct/tcCheck",$("#addOrEditForm").serialize(),function (data) {
                if (data.success){
                    $.messager.alert("温馨提示", "操作成功");
                    $('#grid_data').bootstrapTable('refresh');
                }else {
                    $.messager.alert("温馨提示","操作失败");
                }
            });
        });

        //删除按钮的点击事件
        $("#deleteBtn").click(function () {
            $.messager.confirm("提示", "确认删除?",function () {
                //获取选中行的数据
                var datas = $('#grid_data').bootstrapTable('getSelections');
                //判断是否选中行数据，如果没有则提示
                if(datas.length > 0){
                    var ids='';
                    //填充表单
                    for (var i = 0; i < datas.length; i++) {
                        ids+=','+datas[i].productId;
                    }
                    ids=ids.substring(1,ids.length);
                    //发送请求,执行批量删除
                    $.post("/remote/product/deletePro",{"ids": ids},function (res) {
                        if (res.success){
                            $.messager.alert("温馨提示", "操作成功");
                            $('#grid_data').bootstrapTable('refresh');
                        }else {
                            $.messager.alert("温馨提示","操作失败");
                        }
                    });
                }else{
                    $.messager.alert("温馨提示", "请选择一条数或多条据操作");
                }
            });
        });
    </script>

</div>
</body>
</html>
